#  This file is part of codeogre
#  Copyright (C) 2009 Johan Jordaan (www.johanjordaan.co.za)
#
#  This program is free software: you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation, either version 3 of the License, or
#  (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program.  If not, see <http://www.gnu.org/licenses/>.

import sys
sys.path.append('..\..')
import unittest

from codeogre.fsm import *

class FSMFunctionsTestCases(unittest.TestCase):

    def setUp(self):
      pass

    def test_adding_transition(self):
      fsm = FSM()
      self.assertEqual(0,len(fsm.start_state.out_transitions))
      
      fsm.start_state.add_transition(name='a',transition_function=lambda input,input_index:input[input_index]=='a')
      self.assertEqual(1,len(fsm.start_state.out_transitions))
      self.assertEqual(True,fsm.start_state.out_transitions[0].name == 'a')
      newState = fsm.start_state.out_transitions[0].destination
      self.assertEqual(1,len(newState.in_transitions))
      self.assertEqual(0,len(newState.out_transitions))
      
     
      
      
      
      

suite = unittest.makeSuite(FSMFunctionsTestCases)
          
if __name__ == '__main__':
  unittest.main()
